﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Collections;

namespace Web.Views.ArchiveFlowView
{
    public partial class ArchiveReceiveList : ArchiveFlowPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //基类控件赋值
            // CurrentArchiveKind = ArchiveTableEnum.AudioVedio;
            PassFlowName = hiddenSHTG.Value;
            BackFlowName = hiddenBack.Value;
            gvTransfered = gvDocumentDone;
            gvUnTransfered = gvDocumentUndo;
            pagerTransfered = pagerDone;
            pagerUntransfered = pagerUndo;

            CurrentStatusName = hiddenStatusName.Value;

            this.sch.SearchEvent += new EventHandler(sch_SearchEvent);

            searchCtrl = sch;

            pagerTransfered.PageSizeChanging += new EventHandler(pagerTransfered_PageSizeChanging);
            pagerUntransfered.PageSizeChanging += new EventHandler(pagerUntransfered_PageSizeChanging);

            if (!IsPostBack)
            {
                //调用基类方法初始化页面数据
                InitialData();
            }
            else
            {
                //
            }
        }

        /// <summary>
        /// 查询事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void sch_SearchEvent(object sender, EventArgs e)
        {
            InitialData(this.sch.WhereString);
        }

        /// <summary>
        /// 已办绑定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvDocumentDone_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DataRow row = ((DataRowView)e.Row.DataItem).Row;
                e.Row.Cells[2].Text = IUserService.GetUserNameById(row["CREATEUSERID"].ToString());
                e.Row.Cells[6].Text = ICodeTableService.GetpkNameByCodepkValue(row["F_SECURITYTYPE"].ToString());
                e.Row.Cells[3].Text = string.Format("<a target='_blank' href='ArchiveFlowEdit.aspx?needcheck=1&archiveId={0}&archivetype={1}&currentstatusname={2}' >{3}</a>",
                    row["DATAID"], (int)CurrentArchiveKind, CurrentStatusName,row["TITLE"]);
            }
        }

        protected void bnPrintJuanCatagory_Click(object sender, EventArgs e)
        {
            ArrayList keys = new ArrayList();
            keys = this.gvDocumentUndo.SelectItems;
            keys.AddRange(this.gvDocumentDone.SelectItems);
            if (keys.Count == 0)
            {
                Alert("未选中任何数据！");
                return;
            }
            Session["dasj_jnml_selectedkeys"] = keys;
            this.Response.Redirect(string.Format("PrintJuanCatagoryView.aspx?from=dasj&archiveType={0}", (int)CurrentArchiveKind));
        }

        protected void bnPrintBoxCatagory_Click(object sender, EventArgs e)
        {
            ArrayList keys = new ArrayList();
            keys = this.gvDocumentUndo.SelectItems;
            keys.AddRange(this.gvDocumentDone.SelectItems);
            if (keys.Count == 0)
            {
                Alert("未选中任何数据！");
                return;
            }
            Session["dasj_hnml_selectedkeys"] = keys;
            this.Response.Redirect(string.Format("PrintBoxCatagoryView.aspx?from=dasj&archiveType={0}", (int)CurrentArchiveKind));
        }

        protected void btnPrintBeikaoTable_Click(object sender, EventArgs e)
        {
            ArrayList keys = new ArrayList();
            keys = this.gvDocumentUndo.SelectItems;
            keys.AddRange(this.gvDocumentDone.SelectItems);
            if (keys.Count == 0)
            {
                Alert("未选中任何数据！");
                return;
            }

            Session["dasj_bkb_selectedkeys"] = keys;
            Response.Redirect("../ArchiveFlowView/PrintBeikaoTableView.aspx?from=dasj&archiveType=" + (int)BaseArchiveType);

        }

        /// <summary>
        /// 备注：打印档案交接文具-档案接收
        /// 时间：2013年3月12日 23:21:21
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnPrintHandoverCatagory_Click(object sender, EventArgs e)
        {
            ArrayList keys = new ArrayList();
            keys.AddRange(this.gvDocumentUndo.SelectItems);
            if (this.gvDocumentDone.SelectItems != null) { keys.AddRange(this.gvDocumentDone.SelectItems); }
            if (keys.Count == 0)
            {
                Alert("未选中任何数据！");
                return;
            }
            Session["dajs_selectedkeys_jj"] = keys;
            this.RegisterClientScriptBlock("alert",
                string.Format("<script>window.open('AddHandoverDescView.aspx?from=dajs&archiveType={0}', '_blank', 'width=600,height=445,resizable=no');</script>"
                , (int)CurrentArchiveKind));
            //this.Response.Redirect(string.Format("PrintHandoverCatagory.aspx?from=dajs&archiveType={0}", (int)CurrentArchiveKind));
        }
    }
}